package lily.phs.child;


import lily.phs.object.ThreeChild;
import lily.phs.urh.R;
import lily.ui.control.MyPopupWindow;



import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.text.InputType;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;

public class ThreeToSixChildView_Two extends RelativeLayout implements OnFocusChangeListener,OnClickListener{
	View v;
	Paint paint;
	private LinearLayout ll1;
	MyPopupWindow mPopupWindow;
	//ScrollView sv;
	private int profileid;
	private Context myContext;
	private RadioButton rb_no_1,rb_no_2,rb_no_3,rb_no_4,
					    rb_yes_1,rb_yes_2,rb_yes_3,rb_yes_4;
	
	private CheckBox cb_disease_no_1,cb_disease_no_2,cb_disease_no_3,cb_disease_no_4,
					 cb_disease_feiyan_1,cb_disease_feiyan_2,cb_disease_feiyan_3,cb_disease_feiyan_4,
					 cb_disease_fuxie_1,cb_disease_fuxie_2,cb_disease_fuxie_3,cb_disease_fuxie_4,
					 cb_disease_waishang_1,cb_disease_waishang_2,cb_disease_waishang_3,cb_disease_waishang_4,
					 cb_disease_other_1,cb_disease_other_2,cb_disease_other_3,cb_disease_other_4,
					 cb_1_1,cb_1_2,cb_1_3,cb_1_4,
					 cb_2_1,cb_2_2,cb_2_3,cb_2_4,
					 cb_3_1,cb_3_2,cb_3_3,cb_3_4,
					 cb_4_1,cb_4_2,cb_4_3,cb_4_4,
					 cb_5_1,cb_5_2,cb_5_3,cb_5_4;
	
	private EditText et_feiyan_1,et_feiyan_2,et_feiyan_3,et_feiyan_4,
					 et_fuxie_1,et_fuxie_2,et_fuxie_3,et_fuxie_4,
					 et_waishang_1,et_waishang_2,et_waishang_3,et_waishang_4,
					 et_other_1,et_other_2,et_other_3,et_other_4,
					 et_reason_1,et_reason_2,et_reason_3,et_reason_4,
					 et_inst_1,et_inst_2,et_inst_3,et_inst_4,
					 et_guide_1,et_guide_2,et_guide_3,et_guide_4,
					 et_nextdate_1,et_nextdate_2,et_nextdate_3,et_nextdate_4,
					 et_doctor_1,et_doctor_2,et_doctor_3,et_doctor_4,et;
	
	ThreeChild tc1,tc2,tc3,tc4;
	
	private RadioGroup rg_zz_1,rg_zz_2,rg_zz_3,rg_zz_4;
	
	public ThreeToSixChildView_Two(Context context,int pro) {
		super(context);
		myContext=context;
		this.profileid=pro;
		paint=new Paint();
		paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.BLACK);
        this.setBackgroundColor(Color.WHITE);
	}
	
	public void findWeidget(){
		LayoutInflater factory = LayoutInflater.from(myContext);
        v = factory.inflate(R.layout.threetosix_child_2, null);
        et=(EditText)v.findViewById(R.id.et_sc_xhdb_dffd2);
        et.setInputType(InputType.TYPE_NULL);
        ll1=(LinearLayout)v.findViewById(R.id.ll);
		//sv=(ScrollView)this.findViewById(R.id.ScrollView01);
        cb_disease_no_1=(CheckBox)v.findViewById(R.id.cb_tsc_disease_no_1);
        cb_disease_no_1.requestFocus();
        cb_disease_no_2=(CheckBox)v.findViewById(R.id.cb_tsc_disease_no_2);
        cb_disease_no_3=(CheckBox)v.findViewById(R.id.cb_tsc_disease_no_3);
        cb_disease_no_4=(CheckBox)v.findViewById(R.id.cb_tsc_disease_no_4);
        cb_disease_no_1.setOnClickListener(this);
        cb_disease_no_2.setOnClickListener(this);
        cb_disease_no_3.setOnClickListener(this);
        cb_disease_no_4.setOnClickListener(this);
        cb_disease_feiyan_1=(CheckBox)v.findViewById(R.id.cb_tsc_disease_feiyan_1);
        cb_disease_feiyan_2=(CheckBox)v.findViewById(R.id.cb_tsc_disease_feiyan_2);
        cb_disease_feiyan_3=(CheckBox)v.findViewById(R.id.cb_tsc_disease_feiyan_3);
        cb_disease_feiyan_4=(CheckBox)v.findViewById(R.id.cb_tsc_disease_feiyan_4);
        cb_disease_fuxie_1=(CheckBox)v.findViewById(R.id.cb_tsc_disease_fuxie_1);
        cb_disease_fuxie_2=(CheckBox)v.findViewById(R.id.cb_tsc_disease_fuxie_2);
        cb_disease_fuxie_3=(CheckBox)v.findViewById(R.id.cb_tsc_disease_fuxie_3);
        cb_disease_fuxie_4=(CheckBox)v.findViewById(R.id.cb_tsc_disease_fuxie_4);
        cb_disease_waishang_1=(CheckBox)v.findViewById(R.id.cb_tsc_disease_waishang_1);
        cb_disease_waishang_2=(CheckBox)v.findViewById(R.id.cb_tsc_disease_waishang_2);
        cb_disease_waishang_3=(CheckBox)v.findViewById(R.id.cb_tsc_disease_waishang_3);
        cb_disease_waishang_4=(CheckBox)v.findViewById(R.id.cb_tsc_disease_waishang_4);
        cb_disease_other_1=(CheckBox)v.findViewById(R.id.cb_tsc_disease_other_1);
        cb_disease_other_2=(CheckBox)v.findViewById(R.id.cb_tsc_disease_other_2);
        cb_disease_other_3=(CheckBox)v.findViewById(R.id.cb_tsc_disease_other_3);
        cb_disease_other_4=(CheckBox)v.findViewById(R.id.cb_tsc_disease_other_4);
		
		et_feiyan_1=(EditText)v.findViewById(R.id.et_tsc_feiyan_1);
		et_feiyan_2=(EditText)v.findViewById(R.id.et_tsc_feiyan_2);
		et_feiyan_3=(EditText)v.findViewById(R.id.et_tsc_feiyan_3);
		et_feiyan_4=(EditText)v.findViewById(R.id.et_tsc_feiyan_4);
		et_fuxie_1=(EditText)v.findViewById(R.id.et_tsc_fuxie_1);
		et_fuxie_2=(EditText)v.findViewById(R.id.et_tsc_fuxie_2);
		et_fuxie_3=(EditText)v.findViewById(R.id.et_tsc_fuxie_3);
		et_fuxie_4=(EditText)v.findViewById(R.id.et_tsc_fuxie_4);
		et_waishang_1=(EditText)v.findViewById(R.id.et_tsc_waishang_1);
		et_waishang_2=(EditText)v.findViewById(R.id.et_tsc_waishang_2);
		et_waishang_3=(EditText)v.findViewById(R.id.et_tsc_waishang_3);
		et_waishang_4=(EditText)v.findViewById(R.id.et_tsc_waishang_4);
		et_other_1=(EditText)v.findViewById(R.id.et_tsc_other_1);
		et_other_2=(EditText)v.findViewById(R.id.et_tsc_other_2);
		et_other_3=(EditText)v.findViewById(R.id.et_tsc_other_3);
		et_other_4=(EditText)v.findViewById(R.id.et_tsc_other_4);
		rg_zz_1=(RadioGroup)v.findViewById(R.id.rg_tsc_zz_1);
		rg_zz_2=(RadioGroup)v.findViewById(R.id.rg_tsc_zz_2);
		rg_zz_3=(RadioGroup)v.findViewById(R.id.rg_tsc_zz_3);
		rg_zz_4=(RadioGroup)v.findViewById(R.id.rg_tsc_zz_4);
		rb_no_1=(RadioButton)v.findViewById(R.id.rb_tsc_zz_no_1);
		rb_no_2=(RadioButton)v.findViewById(R.id.rb_tsc_zz_no_2);
		rb_no_3=(RadioButton)v.findViewById(R.id.rb_tsc_zz_no_3);
		rb_no_4=(RadioButton)v.findViewById(R.id.rb_tsc_zz_no_4);
		rb_yes_1=(RadioButton)v.findViewById(R.id.rb_tsc_zz_yes_1);
		rb_yes_2=(RadioButton)v.findViewById(R.id.rb_tsc_zz_yes_2);
		rb_yes_3=(RadioButton)v.findViewById(R.id.rb_tsc_zz_yes_3);
		rb_yes_4=(RadioButton)v.findViewById(R.id.rb_tsc_zz_yes_4);
		et_reason_1=(EditText)v.findViewById(R.id.et_tsc_zz_reason_1);
		et_reason_2=(EditText)v.findViewById(R.id.et_tsc_zz_reason_2);
		et_reason_3=(EditText)v.findViewById(R.id.et_tsc_zz_reason_3);
		et_reason_4=(EditText)v.findViewById(R.id.et_tsc_zz_reason_4);
		et_inst_1=(EditText)v.findViewById(R.id.et_tsc_zz_inst_1);
		et_inst_2=(EditText)v.findViewById(R.id.et_tsc_zz_inst_2);
		et_inst_3=(EditText)v.findViewById(R.id.et_tsc_zz_inst_3);
		et_inst_4=(EditText)v.findViewById(R.id.et_tsc_zz_inst_4);
		cb_1_1=(CheckBox)v.findViewById(R.id.cb_tsc_guide_1_1);
		cb_1_2=(CheckBox)v.findViewById(R.id.cb_tsc_guide_1_2);
		cb_1_3=(CheckBox)v.findViewById(R.id.cb_tsc_guide_1_3);
		cb_1_4=(CheckBox)v.findViewById(R.id.cb_tsc_guide_1_4);
		cb_2_1=(CheckBox)v.findViewById(R.id.cb_tsc_guide_2_1);
		cb_2_2=(CheckBox)v.findViewById(R.id.cb_tsc_guide_2_2);
		cb_2_3=(CheckBox)v.findViewById(R.id.cb_tsc_guide_2_3);
		cb_2_4=(CheckBox)v.findViewById(R.id.cb_tsc_guide_2_4);
		cb_3_1=(CheckBox)v.findViewById(R.id.cb_tsc_guide_3_1);
		cb_3_2=(CheckBox)v.findViewById(R.id.cb_tsc_guide_3_2);
		cb_3_3=(CheckBox)v.findViewById(R.id.cb_tsc_guide_3_3);
		cb_3_4=(CheckBox)v.findViewById(R.id.cb_tsc_guide_3_4);
		cb_4_1=(CheckBox)v.findViewById(R.id.cb_tsc_guide_4_1);
		cb_4_2=(CheckBox)v.findViewById(R.id.cb_tsc_guide_4_2);
		cb_4_3=(CheckBox)v.findViewById(R.id.cb_tsc_guide_4_3);
		cb_4_4=(CheckBox)v.findViewById(R.id.cb_tsc_guide_4_4);
		cb_5_1=(CheckBox)v.findViewById(R.id.cb_tsc_guide_5_1);
		cb_5_2=(CheckBox)v.findViewById(R.id.cb_tsc_guide_5_2);
		cb_5_3=(CheckBox)v.findViewById(R.id.cb_tsc_guide_5_3);
		cb_5_4=(CheckBox)v.findViewById(R.id.cb_tsc_guide_5_4);
		et_guide_1=(EditText)v.findViewById(R.id.et_tsc_guide_1);
		et_guide_2=(EditText)v.findViewById(R.id.et_tsc_guide_2);
		et_guide_3=(EditText)v.findViewById(R.id.et_tsc_guide_3);
		et_guide_4=(EditText)v.findViewById(R.id.et_tsc_guide_4);
		et_nextdate_1=(EditText)v.findViewById(R.id.et_tsc_nextdate_1);
		et_nextdate_2=(EditText)v.findViewById(R.id.et_tsc_nextdate_2);
		et_nextdate_3=(EditText)v.findViewById(R.id.et_tsc_nextdate_3);
		et_nextdate_4=(EditText)v.findViewById(R.id.et_tsc_nextdate_4);
		et_nextdate_1.setInputType(InputType.TYPE_NULL);
		et_nextdate_2.setInputType(InputType.TYPE_NULL);
		et_nextdate_3.setInputType(InputType.TYPE_NULL);
		et_nextdate_4.setInputType(InputType.TYPE_NULL);
		et_nextdate_1.setOnClickListener(this);
		et_nextdate_1.setOnFocusChangeListener(this);
		et_nextdate_2.setOnClickListener(this);
		et_nextdate_2.setOnFocusChangeListener(this);
		et_nextdate_3.setOnClickListener(this);
		et_nextdate_3.setOnFocusChangeListener(this);
		et_nextdate_4.setOnClickListener(this);
		et_nextdate_4.setOnFocusChangeListener(this);
		et_doctor_1=(EditText)v.findViewById(R.id.et_tsc_doctor_1);
		et_doctor_2=(EditText)v.findViewById(R.id.et_tsc_doctor_2);
		et_doctor_3=(EditText)v.findViewById(R.id.et_tsc_doctor_3);
		et_doctor_4=(EditText)v.findViewById(R.id.et_tsc_doctor_4);
		/*LayoutParams lp=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
		this.addView(v,lp);
		
		MyView mv=new MyView(myContext);
		this.addView(mv,lp);*/
		tc1=new ThreeChild(myContext);
		tc1.selectThreeChild(profileid, 1);
		tc2=new ThreeChild(myContext);
		tc2.selectThreeChild(profileid, 2);
		tc3=new ThreeChild(myContext);
		tc3.selectThreeChild(profileid, 3);
		tc4=new ThreeChild(myContext);
		tc4.selectThreeChild(profileid, 4);
	}
	
	public void selectData(){
		tc1.selectThreeChild(profileid, 1);
		tc2.selectThreeChild(profileid, 2);
		tc3.selectThreeChild(profileid, 3);
		tc4.selectThreeChild(profileid, 4);
	}
	
	public void addToView(){
		LayoutParams lp=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
		this.addView(v,lp);
		
		MyView mv=new MyView(myContext);
		this.addView(mv,lp);
	}
	
	public void initView(){
		//ThreeChild tc=new ThreeChild(myContext);
		//tc.selectThreeChild(profileid, 1);
		if(tc1.getTtch_disease()!=null&&tc1.getTtch_disease().length()>0){
			String s[]=tc1.getTtch_disease().split(",");
			if(Integer.parseInt(s[0])==1){
				cb_disease_no_1.setChecked(true);
			}
			else {
				for(int i=0;i<s.length;i++){
					switch(Integer.parseInt(s[i])){
					case 2:
						cb_disease_feiyan_1.setChecked(true);
						if(tc1.getTtch_nenumonia()>0){
							et_feiyan_1.setText(tc1.getTtch_nenumonia()+"");
						}
						break;
					case 3:
						cb_disease_fuxie_1.setChecked(true);
						if(tc1.getTtch_diarrhea()>0){
							et_fuxie_1.setText(tc1.getTtch_diarrhea()+"");
						}
						break;
					case 4:
						cb_disease_waishang_1.setChecked(true);
						if(tc1.getTtch_injury()>0){
							et_waishang_1.setText(tc1.getTtch_injury()+"");
						}
						break;
					case 5:
						cb_disease_other_1.setChecked(true);
						et_other_1.setText(tc1.getTtch_other_disease());
						break;
					}
				}
			}
		}
		if(tc1.getTtch_refe_choi()>0){
			switch(tc1.getTtch_refe_choi()){
			case 1:
				rg_zz_1.check(0);
				rb_no_1.setChecked(true);
				break;
			case 2:
				rg_zz_1.check(1);
				rb_yes_1.setChecked(true);
				et_reason_1.setText(tc1.getTtch_refe_reasion());
				et_inst_1.setText(tc1.getTtch_refe_inst());
				break;
			}
		}
		if(tc1.getTtch_guide()!=null&&tc1.getTtch_guide().length()>0){
			String s[]=tc1.getTtch_guide().split(",");
			for(int i=0;i<s.length;i++){
				switch(Integer.parseInt(s[i])){
				case 1:
					cb_1_1.setChecked(true);
					break;
				case 2:
					cb_2_1.setChecked(true);
					break;
				case 3:
					cb_3_1.setChecked(true);
					break;
				case 4:
					cb_4_1.setChecked(true);
					break;
				case 5:
					cb_5_1.setChecked(true);
					break;
				}
			}
		}
		et_guide_1.setText(tc1.getTtch_guide_des());
		et_nextdate_1.setText(tc1.getTtch_next_date());
		et_doctor_1.setText(tc1.getTtch_doctor());
		//4
		//tc.selectThreeChild(profileid, 2);
		if(tc2.getTtch_disease()!=null&&tc2.getTtch_disease().length()>0){
			String s[]=tc2.getTtch_disease().split(",");
			if(Integer.parseInt(s[0])==1){
				cb_disease_no_2.setChecked(true);
			}
			else {
				for(int i=0;i<s.length;i++){
					switch(Integer.parseInt(s[i])){
					case 2:
						cb_disease_feiyan_2.setChecked(true);
						if(tc2.getTtch_nenumonia()>0){
							et_feiyan_2.setText(tc2.getTtch_nenumonia()+"");
						}
						break;
					case 3:
						cb_disease_fuxie_2.setChecked(true);
						if(tc2.getTtch_diarrhea()>0){
							et_fuxie_2.setText(tc2.getTtch_diarrhea()+"");
						}
						break;
					case 4:
						cb_disease_waishang_2.setChecked(true);
						if(tc2.getTtch_injury()>0){
							et_waishang_2.setText(tc2.getTtch_injury()+"");
						}
						break;
					case 5:
						cb_disease_other_2.setChecked(true);
						et_other_2.setText(tc2.getTtch_other_disease());
						break;
					}
				}
			}
		}
		if(tc2.getTtch_refe_choi()>0){
			switch(tc2.getTtch_refe_choi()){
			case 1:
				rg_zz_2.check(0);
				rb_no_2.setChecked(true);
				break;
			case 2:
				rg_zz_2.check(1);
				rb_yes_2.setChecked(true);
				et_reason_2.setText(tc2.getTtch_refe_reasion());
				et_inst_2.setText(tc2.getTtch_refe_inst());
				break;
			}
		}
		if(tc2.getTtch_guide()!=null&&tc2.getTtch_guide().length()>0){
			String s[]=tc2.getTtch_guide().split(",");
			for(int i=0;i<s.length;i++){
				switch(Integer.parseInt(s[i])){
				case 1:
					cb_1_2.setChecked(true);
					break;
				case 2:
					cb_2_2.setChecked(true);
					break;
				case 3:
					cb_3_2.setChecked(true);
					break;
				case 4:
					cb_4_2.setChecked(true);
					break;
				case 5:
					cb_5_2.setChecked(true);
					break;
				}
			}
		}
		et_guide_2.setText(tc2.getTtch_guide_des());
		et_nextdate_2.setText(tc2.getTtch_next_date());
		et_doctor_2.setText(tc2.getTtch_doctor());
		//5
		//tc.selectThreeChild(profileid, 3);
		if(tc3.getTtch_disease()!=null&&tc3.getTtch_disease().length()>0){
			String s[]=tc3.getTtch_disease().split(",");
			if(Integer.parseInt(s[0])==1){
				cb_disease_no_3.setChecked(true);
			}
			else {
				for(int i=0;i<s.length;i++){
					switch(Integer.parseInt(s[i])){
					case 2:
						cb_disease_feiyan_3.setChecked(true);
						if(tc3.getTtch_nenumonia()>0){
							et_feiyan_3.setText(tc3.getTtch_nenumonia()+"");
						}
						break;
					case 3:
						cb_disease_fuxie_3.setChecked(true);
						if(tc3.getTtch_diarrhea()>0){
							et_fuxie_3.setText(tc3.getTtch_diarrhea()+"");
						}
						break;
					case 4:
						cb_disease_waishang_3.setChecked(true);
						if(tc3.getTtch_injury()>0){
							et_waishang_3.setText(tc3.getTtch_injury()+"");
						}
						break;
					case 5:
						cb_disease_other_3.setChecked(true);
						et_other_3.setText(tc3.getTtch_other_disease());
						break;
					}
				}
			}
		}
		if(tc3.getTtch_refe_choi()>0){
			switch(tc3.getTtch_refe_choi()){
			case 1:
				rg_zz_3.check(0);
				rb_no_3.setChecked(true);
				break;
			case 2:
				rg_zz_3.check(1);
				rb_yes_3.setChecked(true);
				et_reason_3.setText(tc3.getTtch_refe_reasion());
				et_inst_3.setText(tc3.getTtch_refe_inst());
				break;
			}
		}
		if(tc3.getTtch_guide()!=null&&tc3.getTtch_guide().length()>0){
			String s[]=tc3.getTtch_guide().split(",");
			for(int i=0;i<s.length;i++){
				switch(Integer.parseInt(s[i])){
				case 1:
					cb_1_3.setChecked(true);
					break;
				case 2:
					cb_2_3.setChecked(true);
					break;
				case 3:
					cb_3_3.setChecked(true);
					break;
				case 4:
					cb_4_3.setChecked(true);
					break;
				case 5:
					cb_5_3.setChecked(true);
					break;
				}
			}
		}
		et_guide_3.setText(tc3.getTtch_guide_des());
		et_nextdate_3.setText(tc3.getTtch_next_date());
		et_doctor_3.setText(tc3.getTtch_doctor());
		//6
		//tc.selectThreeChild(profileid, 4);
		if(tc4.getTtch_disease()!=null&&tc4.getTtch_disease().length()>0){
			String s[]=tc4.getTtch_disease().split(",");
			if(Integer.parseInt(s[0])==1){
				cb_disease_no_4.setChecked(true);
			}
			else {
				for(int i=0;i<s.length;i++){
					switch(Integer.parseInt(s[i])){
					case 2:
						cb_disease_feiyan_4.setChecked(true);
						if(tc4.getTtch_nenumonia()>0){
							et_feiyan_4.setText(tc4.getTtch_nenumonia()+"");
						}
						break;
					case 3:
						cb_disease_fuxie_4.setChecked(true);
						if(tc4.getTtch_diarrhea()>0){
							et_fuxie_4.setText(tc4.getTtch_diarrhea()+"");
						}
						break;
					case 4:
						cb_disease_waishang_4.setChecked(true);
						if(tc4.getTtch_injury()>0){
							et_waishang_4.setText(tc4.getTtch_injury()+"");
						}
						break;
					case 5:
						cb_disease_other_4.setChecked(true);
						et_other_4.setText(tc4.getTtch_other_disease());
						break;
					}
				}
			}
		}
		if(tc4.getTtch_refe_choi()>0){
			switch(tc4.getTtch_refe_choi()){
			case 1:
				rg_zz_4.check(0);
				rb_no_4.setChecked(true);
				break;
			case 2:
				rg_zz_4.check(1);
				rb_yes_4.setChecked(true);
				et_reason_4.setText(tc4.getTtch_refe_reasion());
				et_inst_4.setText(tc4.getTtch_refe_inst());
				break;
			}
		}
		if(tc4.getTtch_guide()!=null&&tc4.getTtch_guide().length()>0){
			String s[]=tc4.getTtch_guide().split(",");
			for(int i=0;i<s.length;i++){
				switch(Integer.parseInt(s[i])){
				case 1:
					cb_1_4.setChecked(true);
					break;
				case 2:
					cb_2_4.setChecked(true);
					break;
				case 3:
					cb_3_4.setChecked(true);
					break;
				case 4:
					cb_4_4.setChecked(true);
					break;
				case 5:
					cb_5_4.setChecked(true);
					break;
				}
			}
		}
		et_guide_4.setText(tc4.getTtch_guide_des());
		et_nextdate_4.setText(tc4.getTtch_next_date());
		et_doctor_4.setText(tc4.getTtch_doctor());
	}
	
	public boolean saveView(){
		if(et_feiyan_1.getText().toString().replaceAll("\\s", "").length()>8||
				et_feiyan_1.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_feiyan_1.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_feiyan_2.getText().toString().replaceAll("\\s", "").length()>8||
				et_feiyan_2.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_feiyan_2.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_feiyan_3.getText().toString().replaceAll("\\s", "").length()>8||
				et_feiyan_3.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_feiyan_3.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_feiyan_4.getText().toString().replaceAll("\\s", "").length()>8||
				et_feiyan_4.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_feiyan_4.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_fuxie_1.getText().toString().replaceAll("\\s", "").length()>8||
				et_fuxie_1.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_fuxie_1.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_fuxie_2.getText().toString().replaceAll("\\s", "").length()>8||
				et_fuxie_2.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_fuxie_2.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_fuxie_3.getText().toString().replaceAll("\\s", "").length()>8||
				et_fuxie_3.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_fuxie_3.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_fuxie_4.getText().toString().replaceAll("\\s", "").length()>8||
				et_fuxie_4.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_fuxie_4.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_waishang_1.getText().toString().replaceAll("\\s", "").length()>8||
				et_waishang_1.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_waishang_1.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_waishang_2.getText().toString().replaceAll("\\s", "").length()>8||
				et_waishang_2.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_waishang_2.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_waishang_3.getText().toString().replaceAll("\\s", "").length()>8||
				et_waishang_3.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_waishang_3.setError("输入的数据长度超过范围");
			return false;
		}
		if(et_waishang_4.getText().toString().replaceAll("\\s", "").length()>8||
				et_waishang_4.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_waishang_4.setError("输入的数据长度超过范围");
			return false;
		}
		ThreeChild tc=new ThreeChild(myContext);
		tc.selectThreeChild(profileid, 1);
		if(cb_disease_no_1.isChecked()){
			tc.setTtch_disease("1");
		}
		else {
			String str="";
			if(cb_disease_feiyan_1.isChecked()){
				str+="2,";
				if(et_feiyan_1.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_nenumonia(Integer.parseInt(et_feiyan_1.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_fuxie_1.isChecked()){
				str+="3,";
				if(et_fuxie_1.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_diarrhea(Integer.parseInt(et_fuxie_1.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_waishang_1.isChecked()){
				str+="4,";
				if(et_waishang_1.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_injury(Integer.parseInt(et_waishang_1.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_other_1.isChecked()){
				str+="5";
				tc.setTtch_other_disease(et_other_1.getText().toString().replaceAll("\\s", ""));
			}
			tc.setTtch_disease(str);
		}
		if(rb_no_1.isChecked()){
			tc.setTtch_refe_choi(1);
		}
		else if(rb_yes_1.isChecked()){
			tc.setTtch_refe_choi(2);
			tc.setTtch_refe_reasion(et_reason_1.getText().toString().replaceAll("\\s", ""));
			tc.setTtch_refe_inst(et_inst_1.getText().toString().replaceAll("\\s", ""));
		}
		String str="";
		if(cb_1_1.isChecked()){
			str+="1,";
		}
		if(cb_2_1.isChecked()){
			str+="2,";
		}
		if(cb_3_1.isChecked()){
			str+="3,";
		}
		if(cb_4_1.isChecked()){
			str+="4,";
		}
		if(cb_5_1.isChecked()){
			str+="5";
		}
		tc.setTtch_guide(str);
		tc.setTtch_guide_des(et_guide_1.getText().toString().replaceAll("\\s", ""));
		tc.setTtch_next_date(et_nextdate_1.getText().toString().replaceAll("\\s", ""));
		tc.setTtch_doctor(et_doctor_1.getText().toString().replaceAll("\\s", ""));
		tc.updateThreeChild(profileid, 1);
		//4
		tc.selectThreeChild(profileid, 2);
		if(cb_disease_no_2.isChecked()){
			tc.setTtch_disease("1");
		}
		else {
			str="";
			if(cb_disease_feiyan_2.isChecked()){
				str+="2,";
				if(et_feiyan_2.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_nenumonia(Integer.parseInt(et_feiyan_2.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_fuxie_2.isChecked()){
				str+="3,";
				if(et_fuxie_2.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_diarrhea(Integer.parseInt(et_fuxie_2.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_waishang_2.isChecked()){
				str+="4,";
				if(et_waishang_2.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_injury(Integer.parseInt(et_waishang_2.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_other_2.isChecked()){
				str+="5";
				tc.setTtch_other_disease(et_other_2.getText().toString().replaceAll("\\s", ""));
			}
			tc.setTtch_disease(str);
		}
		if(rb_no_2.isChecked()){
			tc.setTtch_refe_choi(1);
		}
		else if(rb_yes_2.isChecked()){
			tc.setTtch_refe_choi(2);
			tc.setTtch_refe_reasion(et_reason_2.getText().toString().replaceAll("\\s", ""));
			tc.setTtch_refe_inst(et_inst_2.getText().toString().replaceAll("\\s", ""));
		}
		str="";
		if(cb_1_2.isChecked()){
			str+="1,";
		}
		if(cb_2_2.isChecked()){
			str+="2,";
		}
		if(cb_3_2.isChecked()){
			str+="3,";
		}
		if(cb_4_2.isChecked()){
			str+="4,";
		}
		if(cb_5_2.isChecked()){
			str+="5";
		}
		tc.setTtch_guide(str);
		tc.setTtch_guide_des(et_guide_2.getText().toString().replaceAll("\\s", ""));
		tc.setTtch_next_date(et_nextdate_2.getText().toString().replaceAll("\\s", ""));
		tc.setTtch_doctor(et_doctor_2.getText().toString().replaceAll("\\s", ""));
		tc.updateThreeChild(profileid, 2);
		//5
		tc.selectThreeChild(profileid, 3);
		if(cb_disease_no_3.isChecked()){
			tc.setTtch_disease("1");
		}
		else {
			str="";
			if(cb_disease_feiyan_3.isChecked()){
				str+="2,";
				if(et_feiyan_3.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_nenumonia(Integer.parseInt(et_feiyan_3.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_fuxie_3.isChecked()){
				str+="3,";
				if(et_fuxie_3.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_diarrhea(Integer.parseInt(et_fuxie_3.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_waishang_3.isChecked()){
				str+="4,";
				if(et_waishang_3.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_injury(Integer.parseInt(et_waishang_3.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_other_3.isChecked()){
				str+="5";
				tc.setTtch_other_disease(et_other_3.getText().toString().replaceAll("\\s", ""));
			}
			tc.setTtch_disease(str);
		}
		if(rb_no_3.isChecked()){
			tc.setTtch_refe_choi(1);
		}
		else if(rb_yes_3.isChecked()){
			tc.setTtch_refe_choi(2);
			tc.setTtch_refe_reasion(et_reason_3.getText().toString().replaceAll("\\s", ""));
			tc.setTtch_refe_inst(et_inst_3.getText().toString().replaceAll("\\s", ""));
		}
		str="";
		if(cb_1_3.isChecked()){
			str+="1,";
		}
		if(cb_2_3.isChecked()){
			str+="2,";
		}
		if(cb_3_3.isChecked()){
			str+="3,";
		}
		if(cb_4_3.isChecked()){
			str+="4,";
		}
		if(cb_5_3.isChecked()){
			str+="5";
		}
		tc.setTtch_guide(str);
		tc.setTtch_guide_des(et_guide_3.getText().toString().replaceAll("\\s", ""));
		tc.setTtch_next_date(et_nextdate_3.getText().toString().replaceAll("\\s", ""));
		tc.setTtch_doctor(et_doctor_3.getText().toString().replaceAll("\\s", ""));
		tc.updateThreeChild(profileid,3);
		//6
		tc.selectThreeChild(profileid, 4);
		if(cb_disease_no_4.isChecked()){
			tc.setTtch_disease("1");
		}
		else {
			str="";
			if(cb_disease_feiyan_4.isChecked()){
				str+="2,";
				if(et_feiyan_4.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_nenumonia(Integer.parseInt(et_feiyan_4.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_fuxie_4.isChecked()){
				str+="3,";
				if(et_fuxie_4.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_diarrhea(Integer.parseInt(et_fuxie_4.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_waishang_4.isChecked()){
				str+="4,";
				if(et_waishang_4.getText().toString().replaceAll("\\s", "").length()>0){
					tc.setTtch_injury(Integer.parseInt(et_waishang_4.getText().toString().replaceAll("\\s", "")));
				}
			}
			if(cb_disease_other_4.isChecked()){
				str+="5";
				tc.setTtch_other_disease(et_other_4.getText().toString().replaceAll("\\s", ""));
			}
			tc.setTtch_disease(str);
		}
		if(rb_no_4.isChecked()){
			tc.setTtch_refe_choi(1);
		}
		else if(rb_yes_4.isChecked()){
			tc.setTtch_refe_choi(2);
			tc.setTtch_refe_reasion(et_reason_4.getText().toString().replaceAll("\\s", ""));
			tc.setTtch_refe_inst(et_inst_4.getText().toString().replaceAll("\\s", ""));
		}
		str="";
		if(cb_1_4.isChecked()){
			str+="1,";
		}
		if(cb_2_4.isChecked()){
			str+="2,";
		}
		if(cb_3_4.isChecked()){
			str+="3,";
		}
		if(cb_4_4.isChecked()){
			str+="4,";
		}
		if(cb_5_4.isChecked()){
			str+="5";
		}
		tc.setTtch_guide(str);
		tc.setTtch_guide_des(et_guide_4.getText().toString().replaceAll("\\s", ""));
		tc.setTtch_next_date(et_nextdate_4.getText().toString().replaceAll("\\s", ""));
		tc.setTtch_doctor(et_doctor_4.getText().toString().replaceAll("\\s", ""));
		tc.updateThreeChild(profileid, 4);
		return true;
	}
	
	class MyView extends View {
    	View v;
    	Paint paint;
    	
		public MyView(Context context) {
			super(context);
			paint=new Paint();
			paint.setStyle(Paint.Style.STROKE);
            paint.setColor(Color.BLACK);
		}
		
		@Override
		public void onDraw(Canvas c){
	        int top=ll1.getTop();
	        int left=ll1.getLeft()-15;
	        int right=ll1.getRight()+15;
	        int bottom=ll1.getBottom();
	        int y=0;//sv.getScrollY();
	        int height=rb_no_1.getHeight();
	        int height2=et_feiyan_1.getHeight();
	        top=top-y-5;
	        bottom=bottom-y;
	        
	        c.drawLine(left, top+130, right, top+130, paint);
	        c.drawLine(left, top+170+1*40+1*height+4*height2, right, top+170+1*40+1*height+4*height2, paint);
	        c.drawLine(left, top+180+2*40+3*height+6*height2, right, top+180+2*40+3*height+6*height2, paint);
	        c.drawLine(left, top+200+3*40+8*height+7*height2, right, top+200+3*40+8*height+7*height2, paint);
	        c.drawLine(left, top+200+4*40+8*height+8*height2, right, top+200+4*40+8*height+8*height2, paint);
	        c.drawLine(left, top+200+5*40+8*height+9*height2, right, top+200+5*40+8*height+9*height2, paint);
	        
	        c.drawLine(left, top+130, left, top+200+5*40+8*height+9*height2, paint);
	        c.drawLine(right, top+130, right, top+200+5*40+8*height+9*height2, paint);
	        c.drawLine(left+115, top+130, left+115, top+200+5*40+8*height+9*height2, paint);
	        c.drawLine(left+275, top+130, left+275, top+200+5*40+8*height+9*height2, paint);
	        c.drawLine(left+435, top+130, left+435, top+200+5*40+8*height+9*height2, paint);
	        c.drawLine(left+595, top+130, left+595, top+200+5*40+8*height+9*height2, paint);
	    }
    	
    }

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		System.out.println("click2");
		if(v==cb_disease_no_1){
			if(cb_disease_no_1.isChecked()){
				cb_disease_feiyan_1.setEnabled(false);
				cb_disease_fuxie_1.setEnabled(false);
				cb_disease_waishang_1.setEnabled(false);
				cb_disease_other_1.setEnabled(false);
			}
			else{
				cb_disease_feiyan_1.setEnabled(true);
				cb_disease_fuxie_1.setEnabled(true);
				cb_disease_waishang_1.setEnabled(true);
				cb_disease_other_1.setEnabled(true);
			}
		}
		else if(v==cb_disease_no_2){
			if(cb_disease_no_2.isChecked()){
				cb_disease_feiyan_2.setEnabled(false);
				cb_disease_fuxie_2.setEnabled(false);
				cb_disease_waishang_2.setEnabled(false);
				cb_disease_other_2.setEnabled(false);
			}
			else{
				cb_disease_feiyan_2.setEnabled(true);
				cb_disease_fuxie_2.setEnabled(true);
				cb_disease_waishang_2.setEnabled(true);
				cb_disease_other_2.setEnabled(true);
			}
		}
		else if(v==cb_disease_no_3){
			if(cb_disease_no_3.isChecked()){
				cb_disease_feiyan_3.setEnabled(false);
				cb_disease_fuxie_3.setEnabled(false);
				cb_disease_waishang_3.setEnabled(false);
				cb_disease_other_3.setEnabled(false);
			}
			else{
				cb_disease_feiyan_3.setEnabled(true);
				cb_disease_fuxie_3.setEnabled(true);
				cb_disease_waishang_3.setEnabled(true);
				cb_disease_other_3.setEnabled(true);
			}
		}
		else if(v==cb_disease_no_4){
			if(cb_disease_no_4.isChecked()){
				cb_disease_feiyan_4.setEnabled(false);
				cb_disease_fuxie_4.setEnabled(false);
				cb_disease_waishang_4.setEnabled(false);
				cb_disease_other_4.setEnabled(false);
			}
			else{
				cb_disease_feiyan_4.setEnabled(true);
				cb_disease_fuxie_4.setEnabled(true);
				cb_disease_waishang_4.setEnabled(true);
				cb_disease_other_4.setEnabled(true);
			}
		}
		else if(v==et_nextdate_1){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tsc_nextdate_1), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_1.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_2){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tsc_nextdate_2), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_2.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_3){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tsc_nextdate_3), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_3.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_4){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tsc_nextdate_4), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_4.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
	}

	@Override
	public void onFocusChange(View v, boolean hasFocus) {
		// TODO Auto-generated method stub
		if(v==et_nextdate_1&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tsc_nextdate_1   ), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_1.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_2&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tsc_nextdate_2   ), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_2.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_3&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tsc_nextdate_3   ), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_3.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_4&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tsc_nextdate_4   ), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_4.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
	}
}
